#include "MyObject.h"
#include <string>

using namespace std;

//template<typename T>
//string toString(const T& t)
//{
//   ostringstream os;
//   os << t;
//   return os.str();
//}

int main()
{
	const int BUFSIZE = 80;
	MyObject * objs[MAXOBJS];
	char buffer[BUFSIZE];
	for (int i = 0; i < MAXOBJS; ++i)
	{
		sprintf_s(buffer, "MyObject%i", i);
		objs[i] = MyObject::create(i, string(buffer));
	}
	//string test = objs[5]->getString();
	cout << "\nObject 5 == " << objs[5]->getString() << endl;
	delete objs[5];
	objs[5] = 0;
	cout << "\nObject 5 == " << objs[4]->getString() << endl;

	cout << "\nCreating another object:\n";
	sprintf_s(buffer, "%s", "anotherOb");
	MyObject* anotherObject = MyObject::create(100, string(buffer));
	cout << "\nanotherObject == " << anotherObject->getString() << endl;
   
	cout << "\nCreating yet another object:\n";
	MyObject* yetAnotherObject = MyObject::create(120, "yetAnothe");
	cout << "\nyetAnotherObject == " << yetAnotherObject->getString() << endl;
   
	// Delete everything (although it's not "necessary"!)
	delete anotherObject;
	delete yetAnotherObject;
	for (int i = 0; i < MAXOBJS; ++i)
		delete objs[i];
	cin.get();
	return 0;
}